import { Injectable, Pipe, PipeTransform } from '@angular/core';
import { CompanySustainableProductsModel } from './models/companySustainableProducts.model';
import { InvolvementAssessmentModel } from '../productInvolvement/models/involvementAssessment.model';

/**
 * Check if an assessment item is among company's involvements or not.
 * 
 * Author: Sorin Spiru
 * Date: 09.03.2018
 */
@Pipe({
    name: 'companyInvolved'
})
@Injectable()
export class CompanyInvolvementPipe implements PipeTransform {
    transform(items: InvolvementAssessmentModel[], company: CompanySustainableProductsModel, involved: boolean): InvolvementAssessmentModel[] {                
        return items.filter(x => involved ? company.indicators.some(i => x.symbol == i.symbol) : !company.indicators.some(i => x.symbol == i.symbol));        
    }
}
